package com.gg.fruit.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gg.dao.FruitMapper;
import com.gg.entity.Fruit;

@Service
public class FruitService {
	@Autowired
	private FruitMapper fruitMapper;

	public List<Fruit> showAllHotFruits() {
		return fruitMapper.selectFruitsByHot();

	}

	public List<Fruit> searchFruitByLikeName(String searchname) {
		// TODO Auto-generated method stub
		return fruitMapper.selectFruitsByLikeName(searchname);
	}

	public List<Fruit> searchFruitsByCategory(String cid) {
		return fruitMapper.selectFruitByCategory(cid);

	}

	public List<Fruit> searchFruitsByPrice(int min, int max) {
		// TODO Auto-generated method stub
		return fruitMapper.selectFruitsByPrice(min, max);
	}

	public List<Fruit> getFruitsByImport(String fimport) {

		if ("1".equals(fimport)) {
			return fruitMapper.selectFruitsByImport(1);

		} else {

			return fruitMapper.selectFruitsByImport(0);
		}
	}

	public Fruit getFruitByid(String fid) {
		return fruitMapper.selectFruitByFid(fid);

	}
}
